from django.conf import settings
from django.contrib.messages.storage import default_storage
from django.utils.deprecation import MiddlewareMixin
from django.http import HttpResponse

class UserAgentMiddleware(MiddlewareMixin):
    def process_request(self, request):
        pass

    def process_response(self, request, response):
        print(request.headers['User-Agent'])
        if request.headers['User-Agent'] not in [
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
            'python-requests/2.32.3',
        ]:
            return HttpResponse('出错')
        return response
